package com.kyl.job;


import com.kyl.service.ReservationService;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * @author WanJl
 * @version 1.0
 * @title ReservationJob
 * @description
 * @create 2025/1/15
 */
@Component
@Slf4j
public class ReservationJob {
    @Resource
    private ReservationService reservationService;

    /**
     * 如果预约时间小于当前时间，则修改预约状态为过期
     * @XxlJob("reservationStatusToExpired") 根据字符串寻找任务调度中心里的任务
     */
    @XxlJob("reservationStatusToExpired")
    public void updateReservationStatus() {
        log.info("预约状态--过期修改---begin...");
        reservationService.updateReservationStatus(LocalDateTime.now());
        log.info("预约状态--过期修改---end...");
    }

}
